<?php

go(function(){

	$server = new Co\Http\Server("0.0.0.0", 50271);

	$server->handle('/websocket',function($request,$ws){

		$ws->upgrade();//向客户端发送websocket握手信息

		$data = $ws->recv();//接受客户端发送的消息

		print_r($data);

		$ws->push("hello 客户端");//向客户端推送消息
		
	});

	$server->handle('/',function($request,$response){

		echo 'abc'.PHP_EOL;
		$response->end('<h1>协程http服务器</h1>');
	});

	$server->start();
});